%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This file is part of the book
%%
%% Algorithmic Graph Theory
%% http://code.google.com/p/graph-theory-algorithms-book/
%%
%% Copyright (C) 2009--2011 Minh Van Nguyen <nguyenminh2@gmail.com>
%%
%% See the file COPYING for copying conditions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DontPrintSemicolon
\SetAlgoNoLine
%%
%% data section
\SetKwData{Min}{min}
%%
%% input
\KwIn{A list $L$ of $n > 1$ elements that can be ordered using the
  relation ``$\leq$''.}
%%
%% output
\KwOut{The same list as $L$, but sorted in nondecreasing order.}
\BlankLine
%%
%% algorithm body
\For{$i \assign 1, 2, \dots, n-1$}{
  $\Min \assign i$\;
  \For{$j \assign i+1, i+2, \dots, n$}{
    \If{$L[j] < L[\Min]$}{
      $\Min \assign j$\;
    }
  }
  swap the values of $L[\Min]$ and $L[i]$\nllabel{alg:selection_sort:swap_values}\;
}
\Return $L$\;
